package xq.gwt.ui.widgets.command;

import xq.gwt.mvc.model.CommandModel;
import xq.gwt.ui.widgets.feedback.DefaultExceptionPresenter;
import xq.gwt.ui.widgets.feedback.DefaultFeedbackPresenter;

public class DefaultCommandProcessor {
	
	public static void processCommand(CommandModel command){
		try {
			if(command == null)
				return;
			
			command.execute();
			if (command.getFeedback()!= null){
				DefaultFeedbackPresenter feedBackPresenter = new DefaultFeedbackPresenter();
				feedBackPresenter.showFeedback(command.getFeedback());				
			}
			
		} catch (Exception e) {
			DefaultExceptionPresenter exceptionPresenter = new DefaultExceptionPresenter();
			exceptionPresenter.showException(e);
		}
	}

}
